<?php
class ControllerShippingFlat extends AdminController {

	public function index() {

		$this->document->setTitle($this->_['heading_title']);

		M('setting/setting');

		if ($this->request->isPost() && $this->validate()) {
			$this->model_setting_setting->editSetting('flat', $this->request->post);

			$this->session->set_flashdata('success', $this->_['text_success']);
			$this->redirect(UA('extension/shipping'));
		}

  		$this->data['breadcrumbs'] = array();

   		$this->data['breadcrumbs'][] = array(
       		'text'      => $this->_['text_home'],
			'href'      => UA('common/home'),
      		'separator' => false
   		);

   		$this->data['breadcrumbs'][] = array(
       		'text'      => $this->_['text_shipping'],
			'href'      => UA('extension/shipping'),
      		'separator' => ' :: '
   		);

   		$this->data['breadcrumbs'][] = array(
       		'text'      => $this->_['heading_title'],
			'href'      => UA('shipping/flat'),
      		'separator' => ' :: '
   		);

		M('localisation/tax_class');
		$this->data['tax_classes'] = $this->model_localisation_tax_class->getTaxClasses();

		M('localisation/geo_zone');
		$this->data['geo_zones'] = $this->model_localisation_geo_zone->getGeoZones();

		$this->display('shipping/flat.tpl');
	}

	protected function validate() {
		if (!$this->hasMP()) {
			$this->setMessage('error_warning', $this->_['error_permission']);
			return false;
		}

		return true;
	}
}
?>